package com.cdz.charger.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cdz.charger.vo.ChargersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cdz.charger.mapper.ChargersMapper;
import com.cdz.charger.domain.Chargers;
import com.cdz.charger.service.IChargersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;

/**
 * 充电桩Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-06
 */
@Service
public class ChargersServiceImpl extends ServiceImpl<ChargersMapper, Chargers> implements IChargersService {
    @Autowired
    private ChargersMapper chargersMapper;

    /**
     * 查询充电桩
     *
     * @param id 充电桩主键
     * @return 充电桩
     */
    @Override
    public Chargers selectChargersById(Long id) {
        return getById(id);
    }

    /**
     * 查询充电桩列表
     *
     * @param chargers 充电桩
     * @return 充电桩
     */
    @Override
    public List<ChargersVo> selectChargersList(Chargers chargers) {
        return chargersMapper.selectChargersList(chargers);
    }

    /**
     * 新增充电桩
     *
     * @param chargers 充电桩
     * @return 结果
     */
    @Override
    public int insertChargers(Chargers chargers) {
            return save(chargers) ? 1 : 0;
    }

    /**
     * 修改充电桩
     *
     * @param chargers 充电桩
     * @return 结果
     */
    @Override
    public int updateChargers(Chargers chargers) {
        return updateById(chargers) ? 1 : 0;
    }

    /**
     * 批量删除充电桩
     *
     * @param ids 需要删除的充电桩主键
     * @return 结果
     */
    @Override
    public int deleteChargersByIds(Long[] ids) {
        return removeByIds(Arrays.asList(ids)) ? 1 : 0;
    }

    /**
     * 删除充电桩信息
     *
     * @param id 充电桩主键
     * @return 结果
     */
    @Override
    public int deleteChargersById(Long id) {
        return removeById(id) ? 1 : 0;
    }

    /**
     * 获取所有空闲状态的充电桩
     * @return
     */
    @Override
    public List<ChargersVo> getAllChargers() {
        List<ChargersVo> list = chargersMapper.getAllChargers();
        return list;
    }
}
